{include file=header.html}
<script language="javascript" type="text/javascript" src="{res file=js/jquery-1.2.6.js}"></script>
<script language="javascript" type="text/javascript" src="{lib file=jquery.plugins/jquery.validate.js}"></script>
<script type="text/javascript">
$(function(){
     $('#company_form').validate({
    	 errorPlacement : function(error, element) {
				var error_td = element.parent('td');
				error_td.find('.field_notice').hide();
				error_td.append(error);
			},
			success : function(label) {
				label.addClass('validate_right').text('OK!');
			},
		onkeyup : false,
		rules : {
			company_id: {
				required: true
			}
		},
		messages : {
			company_id: {
				required: '{$lang.select_assign_company}'
			}
		}
	});
     
     $('#sel_company').change(function(){
    	 var company_id=$(this).val();
    	if(company_id==0 || company_id==''){
    		$('#show_brand').empty();
    		$('#show_brand').html('{$lang.select_assign_company}');
    	}else{
    		$.ajax({
    			url:'index.php?app=member&act=show_brand&company_id='+company_id,
    			type: 'GET',
    			dataType:'json',
    			success: function (data) {
    				if (data.flag==false) {
    					alert(data.msg);
    				}else{
    					$('#show_brand').empty()
    					$.each(data.info,function(key,val){
    						$('#show_brand').append('<input type="checkbox" name="brand_arr[]" value="' + val.brand_id + '" />' + val.brand_name);
    					});
    				}
    			}
    		});
    	} 
     });
});
</script>
<style>
label.error {margin-left:2em; color:#FF0000;}
.tab-frame{width:700px;}
input[type='checkbox']{ vertical-align:middle;
margin-right:5px;}

</style>
<body>
<div class="sub-body">
<div class="tab-frame">
<form id="company_form" method="post">
<table width="100%" cellspacing="0" cellpadding="0" class="tab-display">
	<tr>
		<th width="100" align="right">{$lang.user_name}：</th>
		<td align="left"><span>{$user.user_name}</span></td>
	</tr>
	<tr>
		<th width="100" align="right">{$lang.assign_company}：</th>
		<td align="left">
			<select name="company_id" id="sel_company">
				<option value="">{$lang.select_pls}</option>
				<!-- {foreach from=$companys item=com} -->
				<option value="{$com.company_id}" <!-- {if $user.company_id==$com.company_id} -->selected=true<!-- {/if} -->>{$com.company_name|escape}</option>
				<!-- {/foreach} -->
			</select>
		</td>
	</tr>
	<tr>
		<th width="100" align="right">{$lang.assign_brand}：</th>
		<td align="left">
			<div id="show_brand">
				<!-- {if $user.brand_arr_id} -->
				<!-- {foreach from=$b_arr item=rows} -->
				<input name="brand_arr[]" value="{$rows.brand_id}" type="checkbox" {if in_array($rows.brand_id,$arr)}checked="true"{/if}/>{$rows.brand_name|escape}
				<!-- {foreachelse} -->
					{$lang.select_assign_company}
				<!-- {/foreach} -->
				<!-- {else} -->
					{$lang.select_assign_company}
				<!-- {/if} -->
			</div>
        </td>
	</tr>
	<tr>
		<td colspan="2" align="center"><input type="submit" value="{$lang.submit}" class="btn-2"/></td>
	</tr>
</table>
</form>
<script language="javascript" type="text/javascript" src="{res file=js/tab_color.js}"></script>
</div>
</div>
</body>
</html>